home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / dskhrdldr.lha / NuTrakkerFINAL-Seg.s < prev    next >
Encoding:
Text File  |  1980-01-12  |  4.1 KB  |  175 lines

  1. *****************************************************************************
  2. * TrackDisk.Device Hardware Replacement - By PsyKo 2/5/1993 & 19/5/1993...  *
  3. *****************************************************************************
  4. * Use as Follows:-                                                          *
  5. *                                                                           *
  6. * d0 = Mode Type (0 = Setup and find drives / 1 = Zero Drive Head /         *
  7. *                 2 = Read Sector)                                          *
  8. *****************************************************************************
  9. * Setup Mode will detect for external disk drives.                          *
  10. * This routine returns with d0 = Available drives (Bits 0 to 3 represent    *
  11. * drives 0 to 3, and are set if a drive is present)...                      *
  12. *****************************************************************************
  13. * Zero Mode, call before you start loading sectors, no need to do it every  *
  14. * time, just when a new disk is inserted, or an error occurs..              *
  15. * Just Call with d0 = the drive u wish to zero                              *
  16. *****************************************************************************
  17. * Read Mode will read a set of sectors from a selected drive. This function *
  18. * needs $3400 Bytes reserved as an MFM buffer....                           *
  19. * It uses:-                                                                 *
  20. * d0 = 2 (read mode), d1 = Disk drive, d2 = Start Sector, d3 = End Sector   *
  21. * a0 = Data Address (Fast, Slow or Chip), a1 = MFM Buffer (Chip ONLY!)      *
  22. *                                                                           *
  23. * This routine returns an error code in d0:-                                *
  24. * 0 = Sector read fine,  -1 = End Sector Smaller than start sector...       *
  25. *****************************************************************************
  26. * Copyright 1993 The Retro Corporation.                  Internal use only! *
  27. *****************************************************************************
  28.  
  29.     Opt    c-
  30.     Section    "PsyKos Hard-Trakker",Code_c
  31.  
  32.     IncDir    Df1:
  33.     
  34. DrCon    = $Bfd100
  35. DrRDY    = $Bfe001
  36. Mtr    = 7
  37. Rdy    = 5
  38.  
  39. Start    Movem.l    d0-d7/a0-a6,-(sp) 
  40.     Lea    ErrorType(pc),a6
  41.     Move.l    #0,(a6)
  42.         
  43.     Lea    DriveNo(pc),a6
  44.     Move.w    d1,(a6)+
  45.     Move.w    d2,(a6)+
  46.     Move.w    d3,(a6)+
  47.     Move.l    a0,(a6)+
  48.     Move.l    a1,(a6)
  49.     
  50.     Cmpi.w    #0,d0
  51.     Beq    FindDrives
  52.     Cmpi.w    #1,d0
  53.     Beq    ZeroDrive
  54.     Cmpi.w    #2,d0
  55.     Beq    ReadoSex
  56.     Bra    Quit
  57.     
  58. ZeroDrive    Moveq    #0,d0
  59.     Lea    DriveNo(pc),a6
  60.     Move.w    (a6),d1
  61.     Bsr    Trakker+$20
  62.     Bra    Quit
  63.  
  64. ReadoSex    Move.w    DriveNo(pc),d1
  65.     Bsr    ReadSectors
  66.  
  67. Quit    Movem.l    (sp)+,d0-d7/a0-a6 
  68.     Move.l    ErrorType(pc),d0
  69.     Rts
  70.             
  71. FindDrives    Moveq    #3,d6
  72.     Lea    DriveID(pc),a6
  73.     Lea    DrCon,a0
  74.     Lea    DrRDY,a1
  75.  
  76. GetDriveID    Moveq    #15,d7
  77.     Moveq    #0,d0
  78.     
  79.     Bclr    #Mtr,(a0)
  80.     Bclr    d6,(a0)
  81.     Bset    d6,(a0)
  82.     Bset    #Mtr,(a0)
  83.     Bclr    d6,(a0)
  84. IDLoop    Bset    d6,(a0)
  85.     Bclr    d6,(a0)
  86.     Asl.w    #1,d0    
  87.     Btst    #Rdy,(a1)
  88.     Beq    SetBit
  89.     Bclr    #0,d0
  90.     Bra    NoSet
  91. SetBit    Bset    #0,d0
  92. NoSet    Bset    d6,(a0)
  93.     Dbf    d7,IDLoop
  94.     Move.w    d0,(a6)+
  95.     Addq    #1,d6
  96.     Cmpi.b    #7,d6
  97.     Bne    GetDriveID
  98.  
  99. ZeroDrives    Lea    DriveID(pc),a4
  100.     Moveq    #0,d1
  101.     Moveq    #0,d3
  102. ZeroLoop    Move.w    (a4)+,d2
  103.     Cmpi.w    #-1,d2
  104.     Bne    NoZeroDrive
  105.     Bset    d1,d3
  106. NoZeroDrive    Addq    #1,d1
  107.     Cmpi.b    #4,d1
  108.     Bne    ZeroLoop
  109.     Lea    ErrorType(pc),a6
  110.     Move.l    d3,(a6)
  111.     Bra    Quit
  112.  
  113. ReadSectors    Cmp.w    d2,d3
  114.     Bge    CorrectSec
  115.     Bra    WrongSecs
  116.     
  117. CorrectSec    Moveq    #1,d0
  118.     Moveq    #0,d1
  119.     Move.w    DriveNo(pc),d1
  120.     Bsr    Trakker+$20
  121.     
  122. GetNextSec    Moveq    #2,d0
  123.     Move.w    CurrentSec(pc),d1
  124.     Lea    DataBuffer(pc),a6
  125.     Move.l    0(a6),a0
  126.     Move.l    4(a6),a1
  127.     Bsr    Trakker+$20
  128.     
  129.     Lea    CurrentSec(pc),a6
  130.     Move.w    0(a6),d1
  131.     Move.w    2(a6),d2
  132.     Cmp.w    d1,d2
  133.     Beq    NoMoreSex
  134.     
  135.     Lea    CurrentSec(pc),a6
  136.     Add.w    #1,0(a6)
  137.     Lea    DataBuffer(pc),a6
  138.     Add.l    #$200,(a6)
  139.     Bra    GetNextSec
  140.     
  141. NoMoreSex    Moveq    #3,d0
  142.     Moveq    #0,d1
  143.     Move.w    DriveNo(pc),d1
  144.     Bsr    Trakker+$20
  145.     Rts
  146.     
  147. WrongSecs    Rts
  148.     
  149. Set0Track0    Dc.w    0
  150. Set0Track1    Dc.w    0
  151. Set0Track2    Dc.w    0
  152. Set0Track3    Dc.w    0
  153.  
  154. ErrorType    Dc.l    0
  155. DriveID    Dc.w    0,0,0,0
  156. DriveCount    Dc.w    0
  157. DriveNo    Dc.w    0
  158. CurrentSec    Dc.w    0
  159. LastSec    Dc.w    0
  160. DataBuffer    Dc.l    0
  161. MFMBuffer    Dc.l    0
  162.  
  163. MSG    Dc.b    "TrackDisk.Replacement by PsyKo/Retro Corp 1993",0
  164.     Even
  165. Trakker    Incbin    MyMateMarmite/DTrakkerFINAL-Seg
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.